from rest_framework import serializers
from myapp.models import *


class UserSerializer(serializers.ModelSerializer):
    # username = serializers.CharField(source='userid.username', read_only=True)
    class Meta:
        model = User
        fields = "__all__"

class BookSerializer(serializers.ModelSerializer):
    # username = serializers.CharField(source='userid.username', read_only=True)
    class Meta:
        model = Books
        fields = "__all__"

class GouSerializer(serializers.ModelSerializer):
    bookname = serializers.CharField(source='bookid.name', read_only=True)
    price = serializers.CharField(source='bookid.price', read_only=True)
    class Meta:
        model = GouWuChe
        fields = "__all__"
class YouSerializer(serializers.ModelSerializer):
    # bookname = serializers.CharField(source='bookid.name', read_only=True)
    # price = serializers.CharField(source='bookid.price', read_only=True)
    class Meta:
        model = YouHuiJuan
        fields = "__all__"

